<template>
	<view>
		<form action="">
			<view class="item">
				<label for="">手机号:</label>
				<input type="text" id="" name="phone" placeholder="请输入手机号"/>
			</view>
			<view class="item">
				<label for="">密&nbsp;&nbsp;&nbsp;码:</label>
				<input type="text" id="" name="password" placeholder="请输入密码"/>
			</view>
		</form>
		<view class="button">
			<button type="submit" @click="loginFn()">登录</button>
			<button type="reset">重置</button>
		</view>
		
	</view>
	<view class="">
		<text>还没有注册？</text>
		<button @click="toReg()">去注册</button>
	</view>
	
</template>

<script setup>
	function loginFn(){
		uni.request({
			url:"http://47.94.6.186:3001/api/user/login",
			method:"POST",
			data:{
				loginname:'',
				password:''
			},
			success(res) {
				console.log(res.data);
				uni.setStorageSync("token",res.data.data.token)
				uni.setStorageSync("userid",res.data.data.userid)
				uni.navigateTo({
					url:"/pages/productDetail/productDetail"
				})
			}
		})
	}
	function toReg(){
		uni.navigateTo({
			url:"/pages/reg/reg"
		})
	}
</script>

<style scoped>
	label{
		width: 70px;
	}
	.item{
		display: flex;
		margin: 10px;
	}
	input{
		line-height: 40px;
		border: 1px solid;
	}
	.button{
		display: flex;
	}
</style>
